#+TITLE: My personal Gnus Configuration
#+AUTHOR:Joshua Branson
#+LATEX_HEADER: \usepackage{lmodern}
#+LATEX_HEADER: \usepackage[QX]{fontenc}
* Setting up my email account name and real name
:PROPERTIES:
:ID:       cf099083-3b27-4d29-bec3-346fc3d0ca3b
:END:
#+BEGIN_SRC emacs-lisp
  (setq
   user-mail-address "jbranso@dismail.de"
   user-full-name	"Joshua Branson")
#+END_SRC

* Getting Mail
:PROPERTIES:
:ID:       44a30b3b-d863-4bf8-a56f-975b987ef4ab
:END:

Gnus has a concept of a main account and secondary accounts.  Your main account is Gnus default account.  It might be worth it, to just not use =gnus-select-method=, and instead create accounts in gnus-secondary-select-methods.
#+BEGIN_SRC emacs-lisp
  ;; (setq gnus-select-method
  ;;       '(nnimap "imap.dismail.de"
  ;;                (nnir-search-engine notmuch)
  ;;                (nnimap-stream ssl)))

  (setq gnus-secondary-select-methods
        '(
          ;; I would like to use gnus as my maildir, but imap works just fine for now.
          ;; (nnmaildir "dismail.de"
          ;;            (nnir-search-engine notmuch)
          ;;            (nnir-notmuch-additional-switches "search")
          ;;            (directory "~/.mail/dismail/"))
          ;; (nnmaildir "fastmail" (directory "~/.mail/"))
          (nntp "news.gwene.org")
          (nntp "news.gmane.io")
          ;; this makes gnus startup super slow!!! (nnmaildir
          ;; "dismail.de" (directory "~/.mail/dismail.de/"))

          (nnimap "gnucode.me"
                  (nnimap-stream ssl)
                  (nnimap-address "imap.gnucode.me")
                ;; for now I have to NOT set this us as joshua@gnucode.me, because auth_username_format
                ;; seems to delete the domain name after login.
                  (nnimap-user "joshua"))

          ;; this is the right config, but I'm not certain how to set up a dovecot username and password
          (nnimap "localDismail"
                  (nnimap-address "localhost")
                  (nnimap-stream network)
                  (nnimap-server-port 143)
                  ;;(nnimap-user "jbranso@dismail.de")
                  )))

#+END_SRC

* Posting Styles
 #+BEGIN_SRC emacs-lisp :tangle no
   (setq gnus-posting-styles
         '(
           ;; My default fastmail posting style
           (".*"
            (signature "Joshua Branson")
            (address "jbranso@dismail.de"))
           ;; when I post to my normal account.
           ))

   #+END_SRC
* Sending Mail
:PROPERTIES:
:ID:       36fc32fe-aa47-4786-afc1-7467613b8506
:END:
#+BEGIN_SRC emacs-lisp

;;(require 'smtpmail)
;; smtp hotmail uses STARTTLS
(setq message-send-mail-function 'smtpmail-send-it
      ;;smtpmail-starttls-credentials '(("smtp-mail.outlook.com" 587 nil nil))
      ;;smtpmail-auth-credentials '(("smtp-mail.outlook.com" 587 "example@hotmail.com" nil))
      ;;smtpmail-default-smtp-server "smtp-mail.outlook.com"
      smtpmail-smtp-server "smtp.dismail.de"
      smtpmail-smtp-service 587)

      ;;just testing this out
(setq sendmail-program "msmtp")
#+END_SRC
* bbdb
:PROPERTIES:
:ID:       8b6a4d87-b98a-47f9-8297-550eaa11c051
:END:
#+BEGIN_SRC emacs-lisp
  (setq bbdb-user-mail-names "jbranso@dismail.de")
#+END_SRC

   Gnus will recognize these email addresses as mine.

   #+BEGIN_SRC emacs-lisp
   (setq
     bbdb-user-mail-address-re
     (regexp-opt
      '("jbranso@dismail.de"))
     message-dont-reply-to-names bbdb-user-mail-address-re
     gnus-ignored-from-addresses bbdb-user-mail-address-re)
   #+END_SRC

* COMMENT Deleting Mail
:PROPERTIES:
:ID:       e6bfe643-5f53-47f2-950c-9d151862fc7b
:END:
The normal action taken when expiring articles is to delete them.  However, in some circumstances it might make more sense to move
them to other groups instead of deleting them.  The variable ‘nnmail-expiry-target’ (and the ‘expiry-target’ group parameter)
controls this.  The variable supplies a default value for all groups, which can be overridden for specific groups by the group
parameter.  default value is ‘delete’, but this can also be a string (which should be the name of the group the message should be
moved to), or a function (which will be called in a buffer narrowed to the message in question, and with the name of the group
being moved from as its parameter) which should return a target—either a group name or ‘delete’.

Here’s an example for specifying a group name.  This example is pretty bad.  It will move all expired articles to my hotmail deleted group.

#+BEGIN_SRC emacs-lisp
;; (setq nnmail-expiry-target "Deleted")
#+END_SRC

Gnus provides a function ‘nnmail-fancy-expiry-target’ which will expire mail to groups according to the variable
‘nnmail-fancy-expiry-targets’.  Here’s an example:

#+BEGIN_SRC emacs-lisp
(setq nnmail-expiry-target 'nnmail-fancy-expiry-target
      nnmail-fancy-expiry-targets
      '((to-from "example@hotmail.com" "Deleted")
        ("subject" "IMPORTANT" "nnfolder:IMPORTANT.%Y.%b")
        ("from" ".*" "Deleted")))
#+END_SRC

With this setup, any mail that has ‘IMPORTANT’ in its Subject header
and was sent in the year ‘YYYY’ and month ‘MMM’, will get expired to the
group ‘nnfolder:IMPORTANT.YYYY.MMM’.  If its From or To header contains
the string ‘example@school.edu’, it will get expired to ‘Deleted’, which
is my hotmail trash folder..  All other mail will get expired to
‘nnfolder:Archive-YYYY’.

* provide this file
:PROPERTIES:
:ID:       bf9f6f2f-44ef-4e42-81b5-49750423a075
:END:
#+BEGIN_SRC emacs-lisp
(provide 'init-gnus-secret)
#+END_SRC
